package com.example.robertluozizhao.framecollectdemo.activity;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;

import com.example.robertluozizhao.framecollectdemo.R;
import com.example.robertluozizhao.framecollectdemo.adapter.NormalTextAdapter;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Lzz on 8/9/2019.
 */

public class ViewAnimationActivity extends AppCompatActivity {


    @BindView(R.id.rv)
    RecyclerView mRv;
    @BindView(R.id.rv1)
    RecyclerView mRv1;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_animation);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        ArrayList<String> strings = new ArrayList<>();
        ArrayList<String> strings1 = new ArrayList<>();
        for (int i = 1; i < 51; i++) {
            if (i % 2 != 0) {
                strings.add("第" + i + "个");
            } else {
                strings1.add("第" + i + "个");
            }
        }

        mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        NormalTextAdapter normalTextAdapter = new NormalTextAdapter(strings);
        mRv.setAdapter(normalTextAdapter);

        mRv1.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        NormalTextAdapter normalTextAdapter1 = new NormalTextAdapter(strings1);
        mRv1.setAdapter(normalTextAdapter1);
        LayoutAnimationController layoutAnimationController = AnimationUtils.loadLayoutAnimation(this, R.anim.anim_list1);
        layoutAnimationController.setDelay(0.8f);
        layoutAnimationController.setOrder(LayoutAnimationController.ORDER_NORMAL);
        mRv1.setLayoutAnimation(layoutAnimationController);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
